﻿using System;
using System.Windows.Data;

namespace Utils.WP7.Bing
{
    public class KilometersConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double distance = (double)value;
            if (distance < 1)
            {
                return String.Format("{0} m", distance * 1000);
            }
            else
            {
                return String.Format("{0} km", Math.Round(distance, 1));
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
